package com.api.shopapi.service.impl;



import com.api.shopapi.entity.Version;
import com.api.shopapi.mapper.VersionMapper;
import com.api.shopapi.service.VersionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("VersionServiceImplOne")
public class VersionServiceImpl implements VersionService {

    @Autowired
    private VersionMapper versionMapper;

    @Override
    public int insert(Version version){
        return versionMapper.insert(version);
    }

    @Override
    public int delete(String versionCode){
        return versionMapper.delete(versionCode);
    }

    @Override
    public int update(Version version){
        return versionMapper.update(version);
    }

    @Override
    public Version getByVersionCode(String versionCode){
        return versionMapper.getByVersionCode(versionCode);
    }

    @Override
    public Version getByName(String name){
        return versionMapper.getByName(name);
    }

    @Override
    public Version getByVersion(String version) {
        return versionMapper.getByVersion(version);
    }

    @Override
    public PageInfo<Version> getPageList(int pageIndex, int pageSize, String name, String version) {
        PageHelper.startPage(pageIndex,pageSize);
        List<Version> versionList = versionMapper.getPageList(name, version);
        return new PageInfo<>(versionList);
    }


}
